1. Field of the Invention
The present invention generally relates to computer database systems. More particularly, the invention relates to methods for processing a database query when the results of a given query may need to be presented in multiple presentation styles, formats, or arrangements.
2. Description of the Related Art
Computer databases are well known systems used to store, maintain, and retrieve data. Generally, a database is a collection of data that is organized in a manner to allow its contents to be easily accessed, managed, and updated. The most prevalent type of database used today is the relational database, which organizes data using tables, and relationships between tables. For example, the DB2® family of RDBMS products (relational database management system) available from International Business Machines (IBM) provides a sophisticated commercial implementation of a relational database.
Tables in a relational database include one or more columns. Each column typically specifies a name and a data type (e.g., integer, float, string, etc.), and is used to store a common element of data. For example, in a table storing data related to patients, each patient might be referenced using a patient identification number stored in a “patient ID” column. Data from each row of this table is related to the same patient, and generally referred to as a “record.” Tables that share at least one element in common (e.g., the patient ID column) are said to be “related.” Additionally, tables without a common data element may be related through other tables that do share such elements.
A relational database query may specify which columns to retrieve data from, how to join columns from multiple tables, and conditions that must be satisfied for a particular data record to be included in a query result set. Current relational databases typically process queries composed in an exacting format specified by a query language. For example, the widely used query language SQL (short for Structured Query Language) is supported by virtually every database available today. An SQL query is composed from one or more clauses set off using specific keywords. However, composing a proper SQL query requires that a user understand the structure and content of the relational database (i.e., a schema of tables and columns) as well as the complex syntax of the SQL query language. This complexity often makes it difficult for average users to compose relational database queries.
Accordingly, query applications have been developed to simplify the process of composing a database query. Using such applications, a user may compose a desired query and submit it to the DBMS (database management system) for processing. In response, the DBMS processes the query and returns a set of query results. Typically, the query result includes a table populated with rows that satisfy conditions specified by the query. The query results are presented using an output format provided for a given query application. Additionally, some query applications allow users to specify a format or presentation style for a given query result.
In some cases, however, a user may not know how the results of a query will be used, and often the way query results are used will depend on the results themselves. Thus, the optimal output format may not be known in advance. For example, a user may review the results of a given query to determine whether they include any interesting or sought after data. The format best suited for such a review may be one that highlights different aspects of the query results, or organizes the rows of a query result table in a particular way. As another example, after reviewing a query result table organized in one format, a user may wish to use a statistical analysis program to process the query result. However, the format of the original query results may be incompatible with the format that such an analysis program might require. One approach for obtaining a query result in the desired format is for the user to perform the query a second time, using a different query application, or by specifying the desired output format, presentation or style.
This approach requires a user to execute the same query once for each desired result format, possibly using many query applications in the process. Besides being both redundant and organizationally difficult, this approach may cause considerable delay as interesting queries often require a substantial amount of time to complete. Thus, simply performing the query multiple times often becomes impractical. However, most of the query processing time occurs in evaluating the conditions specified for the query and not selecting the output format presentation or style to use in presenting a user with query result.
Accordingly, there remains a need for a query application that can present query results to a user in multiple desired formats without requiring that the same query be performed multiple times.